import type { AxiosResponse } from 'axios'
import request from '@/utils/request'

const serviceName = import.meta.env.VITE_APP_SREVICE_NAME_CITY_MANAGEMENT

class ContactServe {
  /** 组织架构 */
  orgList<T = any>(data: { id?: string }): Promise<AxiosResponse<T>> {
    return request({
      url: `${serviceName}/addressBook/getDeptStructure`,
      method: 'post',
      data
    })
  }

  /** 最近联系人 */
  recentList<T = any>(): Promise<AxiosResponse<T>> {
    return request({
      url: `${serviceName}/addressBook/getRecentContact`,
      method: 'post'
    })
  }
  /** 未读数量 */
  unreadCount<T = any>(): Promise<AxiosResponse<T>> {
    return request({
      url: `${serviceName}/addressBook/getUnreadCount`,
      method: 'post'
    })
  }
  /** 已读 */
  updateUnreadInfo<T = any>(data = {}): Promise<AxiosResponse<T>> {
    return request({
      url: `${serviceName}/addressBook/updateUnreadInfo`,
      method: 'post',
      data
    })
  }
  /** 用户详情 */
  userDetail<T = any>(data: { id: string }): Promise<AxiosResponse<T>> {
    return request({
      url: `${serviceName}/addressBook/getUserById`,
      method: 'post',
      data
    })
  }
  /** 发送消息 */
  sendMsg<T = any>(data = {}): Promise<AxiosResponse<T>> {
    return request({
      url: `${serviceName}/addressBook/saveContact`,
      method: 'post',
      data
    })
  }
  /** 查询用户 */
  searchUser<T = any>(data: { realName: string }): Promise<AxiosResponse<T>> {
    return request({
      url: `${serviceName}/addressBook/getUserByName`,
      method: 'post',
      data
    })
  }
  /** 对话信息 */
  msgList<T = any>(data: { id: string }): Promise<AxiosResponse<T>> {
    return request({
      url: `${serviceName}/addressBook/getInfoBySendIdAndReceiverId`,
      method: 'post',
      data
    })
  }
}

export default new ContactServe()
